from typing import List


class Solution:
    def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
        dic = {}
        for i in range(len(strs)):
            a = list(strs[i])
            a.sort()
            key = "".join(a)
            if key in dic:
                dic[key].append(strs[i])
            else:
                dic[key] = [strs[i]]
        res = []
        for key in dic:
            res.append(dic[key])
        return res

t = Solution().groupAnagrams(
    ["eat", "tea", "tan", "ate", "nat", "bat"]
)

print(t)